{#**
*
* 功能描述（添加蛋糕模板）
*
* @author suoya <jlusuoya@gmail.com>
* @version 1
*#}
{#include file="header.tpl" title="修改蛋糕" active="cake" #}
{#include file="define.tpl" scope=parent#}

<div class="content middle">
    <div class="ui breadcrumb">
        <a class="section" href="index.php">主页</a>
        <i class="right"></i>
        <a class="section" href="index.php?action=cake.showlist">产品管理</a>
        <i class="right"></i>
        <span class="active section">修改产品</span>
    </div>
    <div>
        <p style='color: #ff8800'>以下所有变更都会造成版本变更，导致用户收藏、购物车等提示失效,不希望变更的，请指定版本不变</p>
        <p style='color: #ff8800'>主页展示规则：按“主页展示”、“新品”、“销量”、“最新修改”优先有选取8个非配件蛋糕，如果不足8个，随机重复到8个。如果想控制主页展示的商品，最好办法就是仅指定8个“主页展示”。</p>
    </div>

    <form class="ui form" action="index.php?action=cake.mod&id={#$data['id']#}" 
          method="POST" enctype="multipart/form-data" onsubmit="return submitForm(this);">
        <div class="inputDIV">
            <label class="title">产品编号：<span class="prompt">*</span></label>
            <div class="ui input" style="width: 400px;">
                <input type="text" name="no" value="{#$data['no']#}" class="input_text" >
                {#foreach $cake_type2 as $k => $v#}
                    <input name="type2" type="radio" value="{#$k#}"{#if $k==1#}checked{#/if#}><label>{#$v#}</label>
                {#/foreach#}
            </div>
            <div class="ui checkbox">
                <input name="visible_check" type="checkbox" value="1" {#if $data['visible'] == 1#}checked="checked"{#/if#}>
                <label>显示（新商品没有价格信息，无法显示，添加价格后指定显示）</label>
            </div>
        </div>
        <div class="inputDIV">
            <label class="title">产品名称：<span class="prompt">*</span></label>
            <div class="ui input">
                <input type="text" name="name" id="name" class="input_text" value="{#$data['name']#}" >
            </div>
        </div>
        <div class="inputDIV">
            <label class="title">所属类别：<span class="prompt">*</span></label>
            <select name='type'>{#foreach $cake_type as $k=>$v#}<option value='{#$k#}'{#if $k == $data['type']#} selected="selected"{#/if#}>{#$v#}</option>{#/foreach#}</select>
        </div>
        <div class="inputDIV">
            <label class="title">保存方式：<span class="prompt">*</span></label>
            <select name='storage'>{#foreach $cake_storage as $v#}<option value='{#$v#}'{#if $v == $info['storage']#} selected="selected"{#/if#}>{#$v#}</option>{#/foreach#}</select>
        </div>
        <div class="inputDIV">
            <label class="title">产品介绍：<span class="prompt">*</span></label>
            <textarea name="introduce" style="width: 400px;" id="introduce" rows="5">{#$data['introduce'][0]#}{#$data['introduce'][1]#}</textarea>
        </div>
        <div class="inputDIV">
            <label class="title">折扣：<span class="prompt"></span></label>
            <div class="ui input">
                <input type="text" name="discount" value="{#$data['discount']*10#}" style="width: 40px;" class="input_text" >
            </div>
            <label class="tip">不打折为10折，小数最多一位。</label>
        </div>
        <div class="inputDIV" style="overflow: visible;">
            <label class="title">蛋糕图片：<span class="prompt">*</span></label>
            <div class="ui icon input">
                <input type="text" name="tmainimg" value="cake_{#$data['id']#}.jpg" readonly="readonly" class="input_text">
                <input class="input_file_upload" type='file' name='mainimg' 
                       id="mainimg" accept='image/*' onchange="changeFileInput('mainimg');" />
            </div>
            <img width='162' height='162' src="{#$web_root['web']#}data/cake/cake_{#$data['id']#}.jpg" alt="蛋糕图片" style="border: 1px solid #CBCBCB; position: absolute; right: 210px; top: 0; z-index: 10;" />
            <label class="tip">图片长宽比例为1:1</label>
        </div>
        <div class="inputDIV">
            <label class="title">口味：</label>
            <div class="ui input">
                <input type="text" name='taste' value='{#$info['taste']#}' class="input_text" />
            </div>
        </div>
        <div class="inputDIV">
            <label class="title">适合人群：</label>
            <div class="ui input"'>
                <input type="text" name='suits' value='{#$info['suits']#}' class="input_text" />
            </div>
        </div>
        <div class="inputDIV">
            <label class="title">甜度：</label>
            <div class="ui input">
                <select name='sweetness'>{#for $foo=1 to 5#}<option value='{#$foo#}'{#if $foo == $info['sweetness']#} selected="selected"{#/if#}>{#$foo#}</option>{#/for#}</select>
            </div>
            <label class="tip">甜度1-5，5为最甜</label>
        </div>
        <div class="inputDIV">
            <label class="title">适合节日：</label>
            <div class="ui input">
                <input type="text" name='holiday' value='{#$info['holiday']#}' class="input_text" />
            </div>
        </div>
        <div class="inputDIV">
            <label class="title">原材料：</label>
            <textarea name="material" style="width: 400px;" rows="5">{#$info['material']#}</textarea>
        </div>
        <div class="inputDIV" style="overflow: visible;">
            <label class="title">营养图片：<span class="prompt">*</span></label>
            <div class="ui icon input">
                <input type="text" name="tshowimg" value="cake_{#$data['id']#}_1.jpg" readonly="readonly" class="input_text">
                <input class="input_file_upload" type='file' name='showimg' 
                       id="showimg" accept='image/*' onchange="changeFileInput('showimg');" />
            </div>
            <img width='250' height='405' src="{#$web_root['web']#}data/cake/cake_{#$data['id']#}_1.jpg" alt="蛋糕图片" style="border: 1px solid #CBCBCB; position: absolute; left: 10px; top: -120px; z-index: 10;" />
            <label class="tip">图片长宽比例为50:81</label>
        </div>
        <div class="inputDIV">
            <label class="title" style="vertical-align: top;">营养成分：</label>
            <div class="sub_inputDiv">
                <label>每100g含</label>
                <div class="inputDIV">
                    <label class='subTitle'>能量</label>
                    <input type="text" name='attr1' value='{#$info['attr1']#}' style='width: 60px;' class="input_text" />
                    <label class="subTitle">千焦</label>
                </div>
                <div class="inputDIV">
                    <label class='subTitle'>蛋白质</label>
                        <input type='text' name='attr2' value='{#$info['attr2']#}' style='width: 60px;' class="input_text" />
                    <label class="subTitle">克</label>
                </div>
                <div class="inputDIV">
                    <label class='subTitle'>脂肪</label>
                        <input type='text' name='attr3' value='{#$info['attr3']#}' style='width: 60px;' class="input_text" />
                    <label class="subTitle">克</label>
                </div>
                <div class="inputDIV">
                    <label class='subTitle'>碳水化合物</label>
                        <input type='text' name='attr4' value='{#$info['attr4']#}' style='width: 60px;' class="input_text" />
                    <label class="subTitle">克</label>
                </div>
                <div class="inputDIV">
                    <label class='subTitle'>钠</label>
                        <input type='text' name='attr5' value='{#$info['attr5']#}' style='width: 60px;' class="input_text" />
                    <label class="subTitle">毫克</label>
                </div>
            </div>
        </div>
        <div class="inputDIV">
            <label class="title">版本不变：</label>
            <div class="ui input">
                <select name='keepver'><option value='0' selected="selected">否</option><option value='1'>是</option></select>
            </div>
            <label class="tip">选择是将不记录修改时间和版本变更</label>
        </div>
        <div class="ui error message">
        </div>
        <div class="inputDIV">
            <input type="button" class="button align_right" value="返回" onclick="gotoUrl('index.php?action=cake.showlist');" />
            <input type="submit" class="button align_right" value="修改" />
        </div>
        <input type='hidden' name='visible' value='' />
    </form>
</div>
<script>

    $('.ui.form').form({
        no: {
            identifier: 'no',
            rules: [
                {
                    type: 'empty',
                    prompt: '请输入产品编号'
                }
            ]
        },
        name: {
            identifier: 'name',
            rules: [
                {
                    type: 'empty',
                    prompt: '请输入产品名称'
                }
            ]
        },
        type: {
            identifier: 'type',
            rules: [
                {
                    type: 'empty',
                    prompt: '请输入所属类别'
                }
            ]
        },
        storage: {
            identifier: 'storage',
            rules: [
                {
                    type: 'empty',
                    prompt: '请输入保存方式'
                }
            ]
        },
        introduce: {
            identifier: 'introduce',
            rules: [
                {
                    type: 'empty',
                    prompt: '请输入产品介绍'
                }
            ]
        },
        tmainimg: {
            identifier: 'tmainimg',
            rules: [
                {
                    type: 'empty',
                    prompt: '请输入蛋糕图片'
                }
            ]
        },
        tshowimg: {
            identifier: 'tshowimg',
            rules: [
                {
                    type: 'empty',
                    prompt: '请输入营养图片'
                }
            ]
        }
    });

    function submitForm(oForm) {
        if (oForm.visible_check.checked == true) {
            oForm.visible.value = '1';
        } else {
            oForm.visible.value = '0';
        }

        return true;
    }

</script>
{#include file="footer.tpl"#}

